<template>
  <div class="mine-collection">
    <van-tabs v-model="type" @click="getBookmarks">
      <van-tab title="新房"></van-tab>
      <van-tab title="二手房"></van-tab>
      <van-tab title="出租"></van-tab>
    </van-tabs>
    <section class="list-all">
      <van-list
        v-model="loading"
        :finished="!needLoading"
        finished-text=""
        @load="load"
      >
        <list-view ref="listView" @itemClick="itemClick" :listData="dataList"></list-view>
      </van-list>
    </section>
  </div>
</template>

<script>
import ListView from '@/components/listview/listview'
import { summaryMixin } from '@/base/mixins/tableMix'
import { toGoods } from '@/utils'
import { mineApi } from '@/api'
export default {
  name: 'mine-appoint',
  mixins: [summaryMixin],
  components: {
    ListView
  },
  async created() {
    this.getBookmarks()
  },
  data() {
    return {
      dataList: [
      ],
      type: 0,
      showBlur: false
    }
  },
  methods: {
    async getBookmarks(index) {
      const res = await mineApi.collectionList({
        pageNo: 1,
        pageSize: 10,
        type: this.type + 1
      })
      if (res.code !== 200) {
        this.showBlur = true
        return
      }
      this.dataList = res.data.records
      console.log('this.dataList', this.dataList)
      if (!this.dataList || !this.dataList.length) {
        this.showBlur = true
      }
    },
    async  _getDataList(data) {
      console.log('data', this.limit, this.page)
      const res = await mineApi.collectionList({
        type: this.type,
        pageSize: this.limit,
        pageNo: this.page
      })
      if (!res.data) {
        res.data = []
        return []
      }
      this.dataList = this.dataList.concat(res.data.records)
      this.needLoading = !(this.limit > this.dataList.length)
      console.log('this.needLoading', this.needLoading)
      return res.data
    },
    itemClick(item) {
      toGoods(item, this)
    },
    async deleteCollecttArray(item) {
      console.log('item', item)
      const res = await mineApi.deleteCollection({ id: item.bookId })
      if (res.code !== 200) {
        return
      }
      this.$toast('删除成功')
      this.getBookmarks()
      console.log('item', item)
    }
  }
}
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
  @import "src/assets/css/mixin.scss";
  @import 'src/assets/css/variables.scss';
.mine-collection{
  overflow: hidden;
  background-color: #fafafa;
  min-height: 100vh;
  font-size: 16px;
}
.list-all{
  margin-top: 10px;
  // background-color: #fff;
  padding: 0 10px;

}
</style>
